oo::class create UnicodeFont {
    superclass Plugin
    variable RenamedPadWidget

    constructor {renamedPadWidget font} {
        set RenamedPadWidget $renamedPadWidget
        my setUnicodeFont $font
    }

    method setUnicodeFont {font} {
        $RenamedPadWidget tag configure Unicode -font $font
    }

    method applyUniocdeFont {from to} {
        $RenamedPadWidget tag add Unicode $from $to
    }

    method applyUniocdeFontAfterInsert {index content args} {
        foreach ids [regexp -inline -all -indices {[\u2E80-\u9FFF]+} $content] {
            foreach {f t} $ids {}
            my applyUniocdeFont "$index +${f}c" "$index +${t}c +1c"
        }
    }

    method applyUniocdeFontAfterReplace {from to content args} {
        my applyUniocdeFontAfterInsert $from $content
    }

    method getPluginEvents {} {
        return {
            {afterInsert applyUniocdeFontAfterInsert}
            {afterReplace applyUniocdeFontAfterReplace}
        }
    }
}